package com.study.algorithm.sort;

public class BubbleSort {


    public static void main(String args[]){
        bubbleSort(new int[]{4,3,2,1,});
    }

    static  void bubbleSort(int[] nums){
        int size = nums.length;
        int temp = 0;

        for (int i= size -1; i > 0 ;i--) {
            for (int j = 0; j < i ; j++) {
                if(nums[j] > nums[j+1]){
                    //交换位置
                    temp = nums[j+1];
                    nums[j+1] = nums[j];
                    nums[j] = temp;
                }
            }
            PrintUtils.printArray(nums);
        }
    }


}


